package com.sys.SysWaterQuality.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sys.common.annotation.Log;
import com.sys.common.core.controller.BaseController;
import com.sys.common.core.domain.AjaxResult;
import com.sys.common.enums.BusinessType;
import com.sys.SysWaterQuality.domain.SysWaterQuality;
import com.sys.SysWaterQuality.service.ISysWaterQualityService;
import com.sys.common.utils.poi.ExcelUtil;
import com.sys.common.core.page.TableDataInfo;

/**
 * 水质实时数据Controller
 * 
 * @author ruoyi
 * @date 2025-09-03
 */
@RestController
@RequestMapping("/SysWaterQuality/SysWaterQuality")
public class SysWaterQualityController extends BaseController
{
    @Autowired
    private ISysWaterQualityService sysWaterQualityService;

    /**
     * 查询水质实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQuality:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWaterQuality sysWaterQuality)
    {
        startPage();
        List<SysWaterQuality> list = sysWaterQualityService.selectSysWaterQualityList(sysWaterQuality);
        return getDataTable(list);
    }

    /**
     * 导出水质实时数据列表
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQuality:export')")
    @Log(title = "水质实时数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWaterQuality sysWaterQuality)
    {
        List<SysWaterQuality> list = sysWaterQualityService.selectSysWaterQualityList(sysWaterQuality);
        ExcelUtil<SysWaterQuality> util = new ExcelUtil<SysWaterQuality>(SysWaterQuality.class);
        util.exportExcel(response, list, "水质实时数据数据");
    }

    /**
     * 获取水质实时数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQuality:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(sysWaterQualityService.selectSysWaterQualityById(id));
    }

    /**
     * 新增水质实时数据
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQuality:add')")
    @Log(title = "水质实时数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWaterQuality sysWaterQuality)
    {
        return toAjax(sysWaterQualityService.insertSysWaterQuality(sysWaterQuality));
    }

    /**
     * 修改水质实时数据
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQuality:edit')")
    @Log(title = "水质实时数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWaterQuality sysWaterQuality)
    {
        return toAjax(sysWaterQualityService.updateSysWaterQuality(sysWaterQuality));
    }

    /**
     * 删除水质实时数据
     */
    @PreAuthorize("@ss.hasPermi('SysWaterQuality:SysWaterQuality:remove')")
    @Log(title = "水质实时数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(sysWaterQualityService.deleteSysWaterQualityByIds(ids));
    }
}
